package com.cangshi.service;


import com.cangshi.dao.GoodsTypeMapper;
import com.cangshi.dao.GroupUserMapper;
import com.cangshi.entity.GoodsType;
import com.cangshi.entity.Group;
import com.cangshi.entity.GroupUserKey;
import com.cangshi.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Eoly on 2017/1/16.
 */
@Service("groupUserService")
public class GroupUserServiceImpl implements GroupUserService{

    @Autowired
    GroupUserMapper groupUserMapper;



    public List<GroupUserKey> findIdByRequestId(GroupUserKey record) {
        return groupUserMapper.selectBySelectiveKey(record);
    }

    public int deleteByGroupIdAndUserId(GroupUserKey record) {
        return groupUserMapper.deleteByPrimaryKey(record);
    }

    public int addUserGroup(GroupUserKey groupUserKey) {
        return groupUserMapper.insertSelective(groupUserKey);
    }

    public Integer getTheNumberGroupJoinedOrUserOwned(GroupUserKey record) {
        return groupUserMapper.selectCountBySelectiveKey(record);
    }

    public List<User> getAllUsersByGroupId(Integer groupId) {
        return groupUserMapper.selectUsersByGroupId(groupId);
    }

    public List<Group> findGroupsByUserIdCheckAndLimit(Integer userId, Group checkGroup, Integer line, Integer next) {
        return groupUserMapper.selectGroupsChecking(userId,checkGroup,line,next);
    }

    public List<Group> findAllGroupsByUserIdCheckAndLimit(Integer userId, Group checkGroup, Integer line, Integer next) {
        return groupUserMapper.selectAllGroupsByUserId(userId,checkGroup,line,next);
    }

}
